package net.melon.plugin.core.interceptor;

import net.esj.basic.core.view.tools.ActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public abstract class AbstractPluginVisibleInterceptor extends
		AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		String ret= doIntercept(invocation);
		setVisible(invocation);
		return ret;
	}

	protected abstract String doIntercept(ActionInvocation invocation)throws Exception;
	
	final void setVisible(ActionInvocation invocation){
		ActionContext.getSession().setAttribute(PluginDefaultBannedInterceptor.BANNED_REQUEST_KEY,visible(invocation));
	}
	
	protected abstract boolean  visible(ActionInvocation invocation);
}
